/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.gbeine.java.depview.beans.converter;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.gbeine.java.depview.model.Feature;

/**
 *
 * @author gbeine
 */
public class FeatureFactory {

    private static final Logger LOGGER = LoggerFactory.getLogger(FeatureFactory.class);
    private static final Map<String, Feature> features = new HashMap<String, Feature>();

    public static Feature createFeature(final String name) {
        Feature  fe;
        if (FeatureFactory.features.containsKey(name)) {
            if (FeatureFactory.LOGGER.isDebugEnabled()) {
                FeatureFactory.LOGGER.debug("FeatureElement " + name + " already exists.");
            }
            fe = FeatureFactory.features.get(name);
        } else {
            if (FeatureFactory.LOGGER.isDebugEnabled()) {
                FeatureFactory.LOGGER.debug("Creating new FeatureElement: " + name);
            }
            fe = new Feature(name);
            FeatureFactory.features.put(name, fe);
        }
        return fe;
    }
}
